package com.chenl.provider.util;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;

public class SnowNextId {
    private static final Long workerId=RandomUtil.randomLong(31);
    private static final Long dataCenterId=RandomUtil.randomLong(31);
    private static final Snowflake SNOWFLAKE = IdUtil.getSnowflake(workerId, dataCenterId);

    public static Long nextId(){
        return SNOWFLAKE.nextId();
    }

    public static void main(String[] args) {
        System.out.println(workerId);
        System.out.println(dataCenterId);
        for (int i = 0; i < 30; i++) {
            long l = SNOWFLAKE.nextId();
            System.out.println(l);
        }
    }
}
